<template>
  <div class="container">
    <div class="binding-phone">
      <div class="item">
        <span class="item-tip">手机号码：</span>
        <input
          placeholder="输入手机号码"
          type="number"
          v-model="phone"
          @input="onCodeInput"
        />
      </div>
      <div class="item">
        <span class="item-tip">验证码：</span>
        <input placeholder="输入验证码" type="number" />
        <span class="get-code gray" @click="getCodeNum">获取验证码</span>
      </div>
      <!-- </block> -->
    </div>

    <div class="btn-box">
      <span v-if="phone" class="sure-btn">确定</span>
      <span v-else class="sure-btn gray">确定</span>
    </div>
  </div>
</template>

<script>
import { mapState, mapActions } from "vuex";
export default {
  data() {
    return {
      phone: "",
    };
  },
  onLoad() {},

  onShow() {
  
  },
  methods: {
     ...mapActions({
      getCodeNumber: "user/getCodeNumber",
    }),
    //输入手机号
    onCodeInput(e) {
      console.log(e);
      console.log("ee", e.detail.value);
      this.phone = e.detail.value;
    },
      //点击验证码
    getCodeNum  () {
      if(!this.phone){
        wx.showToast({
        title: '请输入手机号',
        icon: "error" 
        })
      }else{
       //获取验证吗
      this.getCodeNumber(this.phone); 
      }
      
    }
  },
};
</script>

<style>
page {
  background: #f4f4f4;
}

.binding-phone {
  height: 100%;
  margin-top: 20rpx;
  background: #fff;
}

.binding-phone .item {
  display: flex;
  padding: 20rpx 0;
  height: 60rpx;
  line-height: 60rpx;
  border-bottom: 2rpx solid #e1e1e1;
}

.binding-phone .item:last-child {
  border: none;
}

.binding-phone .item input {
  flex: 1;
  height: auto;
  padding: 0 20rpx;
  font-size: 28rpx;
}

.binding-phone .item .item-tip {
  width: 140rpx;
  font-size: 28rpx;
  padding-left: 20rpx;
}

.binding-phone .item .get-code {
  font-size: 30rpx;
  color: #999;
  margin-right: 20rpx;
  text-align: center;
}

.binding-phone .item .get-code.gray {
  color: #3eb370;
}

.btn-box {
  padding: 0 20rpx;
  margin-top: 60rpx;
}

.btn-box .sure-btn {
  display: block;
  font-size: 32rpx;
  color: #fff;
  background: #3eb370;
  width: 100%;
  margin: auto;
  text-align: center;
  padding: 20rpx 0;
  border-radius: 50rpx;
}

.btn-box .sure-btn.gray {
  background: #e1e1e1;
  margin-bottom: 30rpx;
}
</style>
